﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BCZadmin
{
    public class DocumentHelp
    {
        private string path;//带文件名
        public Dictionary<string, string> rd = null;
        public DocumentHelp(string p)
        {
            path = p;
        }
        public void Read()
        {
            using (FileStream record = new FileStream(path, FileMode.OpenOrCreate))
            {
                using (StreamReader read = new StreamReader(record))
                {
                    string r;
                    for (rd = new Dictionary<string, string>(); (r = read.ReadLine()) != null;)
                    {
                        var array = r.Split(',');
                        rd.Add(array[0], array[1]);
                    }
                }
            }
        }
        public void Write(string id, string pwd)
        {
            using (FileStream record = new FileStream(Application.StartupPath + @"\record.config", FileMode.Create))
            {
                using(StreamWriter write = new StreamWriter(record))
                {
                        write.WriteLine(id+ "," + pwd);
                }
            }
        }
    }
}
